<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <span th:include="~{inc::myjs}"></span>
    <script>
        $(function (){
            $(".btn-warning").click(function (){
                if(confirm("确认要删除吗？")){
                    let id=$(this).val();
                    $.get(
                        'del/'+id,
                        function (obj){
                            if(obj){
                                alert("删除成功！");
                                location.reload();
                            }else{
                                alert("删除失败！");
                            }
                        }
                    )
                }
            })
        })
    </script>
</head>
<body>
<div class="container">
    <form>
        <input type="text" name="dname" th:value="${dname}">
        <button class="btn btn-info">搜索</button>
    </form>
    <table class="table table-hover table-bordered">
        <tr>
            <th>编号</th>
            <th>名称</th>
            <th>归属</th>
            <th>
                <button class="btn btn-success" onclick="location='add'">新增</button>
            </th>
        </tr>
        <tr th:each="dept:${list}" th:object="${dept}">
            <td th:text="*{deptno}"></td>
            <td th:text="*{dname}"></td>
            <td th:text="*{db_source}"></td>
            <td>
                <button class="btn btn-warning" th:value="*{deptno}">删除</button>
                <button class="btn btn-primary" th:value="*{deptno}">编辑</button>
            </td>
        </tr>
<!--        <tr>-->
<!--            <td colspan="10" align="center">-->
<!--                共<span th:text="${pager.pages}"></span>页，共<span th:text="${pager.total}"></span>条数据。-->
<!--                当前是<span th:text="${pager.pageNum}"></span>页。-->
<!--                <a th:href="@{depts(offset=1)}">首页</a>-->
<!--                <a th:href="@{depts(offset=${pager.pageNum-1})}" th:if="${pager.hasPreviousPage}">上页</a>-->
<!--                <a th:href="@{depts(offset=${pager.pageNum+1})}" th:if="${pager.hasNextPage}">下页</a>-->
<!--                <a th:href="@{depts(offset=${pager.pages})}">末页</a>-->

<!--            </td>-->
<!--        </tr>-->
    </table>
</div>
</body>
</html>
